USE [master]
GO
/****** Object:  Database [bd_scie]    Script Date: 05/06/2009 00:53:26 ******/
CREATE DATABASE [bd_scie] ON  PRIMARY 
( NAME = N'bd_scie', FILENAME = N'c:\Arquivos de programas\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\bd_scie.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'bd_scie_log', FILENAME = N'c:\Arquivos de programas\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\bd_scie_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
 COLLATE Latin1_General_CI_AS
GO
EXEC dbo.sp_dbcmptlevel @dbname=N'bd_scie', @new_cmptlevel=90
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [bd_scie].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [bd_scie] SET ANSI_NULL_DEFAULT OFF 
GO
ALTER DATABASE [bd_scie] SET ANSI_NULLS OFF 
GO
ALTER DATABASE [bd_scie] SET ANSI_PADDING OFF 
GO
ALTER DATABASE [bd_scie] SET ANSI_WARNINGS OFF 
GO
ALTER DATABASE [bd_scie] SET ARITHABORT OFF 
GO
ALTER DATABASE [bd_scie] SET AUTO_CLOSE OFF 
GO
ALTER DATABASE [bd_scie] SET AUTO_CREATE_STATISTICS ON 
GO
ALTER DATABASE [bd_scie] SET AUTO_SHRINK OFF 
GO
ALTER DATABASE [bd_scie] SET AUTO_UPDATE_STATISTICS ON 
GO
ALTER DATABASE [bd_scie] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO
ALTER DATABASE [bd_scie] SET CURSOR_DEFAULT  GLOBAL 
GO
ALTER DATABASE [bd_scie] SET CONCAT_NULL_YIELDS_NULL OFF 
GO
ALTER DATABASE [bd_scie] SET NUMERIC_ROUNDABORT OFF 
GO
ALTER DATABASE [bd_scie] SET QUOTED_IDENTIFIER OFF 
GO
ALTER DATABASE [bd_scie] SET RECURSIVE_TRIGGERS OFF 
GO
ALTER DATABASE [bd_scie] SET  ENABLE_BROKER 
GO
ALTER DATABASE [bd_scie] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO
ALTER DATABASE [bd_scie] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO
ALTER DATABASE [bd_scie] SET TRUSTWORTHY OFF 
GO
ALTER DATABASE [bd_scie] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO
ALTER DATABASE [bd_scie] SET PARAMETERIZATION SIMPLE 
GO
ALTER DATABASE [bd_scie] SET  READ_WRITE 
GO
ALTER DATABASE [bd_scie] SET RECOVERY SIMPLE 
GO
ALTER DATABASE [bd_scie] SET  MULTI_USER 
GO
ALTER DATABASE [bd_scie] SET PAGE_VERIFY CHECKSUM  
GO
ALTER DATABASE [bd_scie] SET DB_CHAINING OFF 

USE bd_scie

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PLACA_MAE]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PLACA_MAE](
	[ID] [int] NOT NULL,
 CONSTRAINT [PK_PLACA_MAE] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PLACA_REDE]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PLACA_REDE](
	[ID] [int] NOT NULL,
 CONSTRAINT [PK_PLACA_REDE] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SOFTWARE]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SOFTWARE](
	[ID] [int] NOT NULL,
 CONSTRAINT [PK_SOFTWARE] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EQUIPAMENTO_HD]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[EQUIPAMENTO_HD](
	[ETIQUETA_EQUIPAMENTO] [int] NULL,
	[ETIQUETA_HD] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PROCESSADOR]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PROCESSADOR](
	[ID] [int] NOT NULL,
 CONSTRAINT [PK_PROCESSADOR] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PLACA_DE_VIDEO]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[PLACA_DE_VIDEO](
	[ID] [int] NOT NULL,
 CONSTRAINT [PK_PLACA_DE_VIDEO] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ETIQUETA]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ETIQUETA](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[DATA_GERACAO] [datetime] NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EQUIPAMENTO]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[EQUIPAMENTO](
	[ETIQUETA] [nvarchar](128) NOT NULL,
	[DATA_ENTRADA] [nvarchar](32) NULL,
	[DATA_BAIXA] [nvarchar](32) NULL,
	[SALA] [nvarchar](8) NULL,
	[DEPARTAMENTO] [nvarchar](16) NULL,
	[STATUS] [nvarchar](16) NULL,
	[OBSERVACAO] [nvarchar](255) NULL,
PRIMARY KEY CLUSTERED 
(
	[ETIQUETA] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MONITOR]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[MONITOR](
	[MARCA] [varchar](64) NULL,
	[MODELO] [varchar](64) NULL,
	[CORES] [varchar](32) NULL,
	[TAMANHO_TELA] [float] NULL,
	[TIPO] [varchar](64) NULL,
	[FREQUENCIA] [varchar](64) NULL,
	[TIPO_CONEXAO] [varchar](32) NULL,
	[VOLTAGEM] [nvarchar](8) NULL,
	[ETIQUETA] [nvarchar](32) NOT NULL,
 CONSTRAINT [PK_Monitor] PRIMARY KEY CLUSTERED 
(
	[ETIQUETA] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[HD]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[HD](
	[ID] [int] NOT NULL,
 CONSTRAINT [PK_HD] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[NOTEBOOK]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[NOTEBOOK](
	[BERCO] [nvarchar](50) NULL,
	[ENTRADA_USB] [int] NULL,
	[TECLADO] [nvarchar](10) NOT NULL,
	[MIDIA] [nvarchar](10) NULL,
	[SAIDA_VIDEO] [nvarchar](5) NULL,
	[ENTRADA_PCMCIA] [nvarchar](30) NULL,
	[ENTRADA_CARTAO] [nvarchar](12) NULL,
	[WEBCAM] [nvarchar](6) NULL,
	[BATERIA] [nvarchar](50) NOT NULL,
	[ADAPTADOR] [nvarchar](6) NOT NULL,
	[NUM_LICENCA] [nvarchar](30) NULL,
	[NUM_SERIE] [nvarchar](50) NULL,
	[ETIQUETA] [nvarchar](128) NOT NULL,
	[HD] [int] NULL,
	[PLACA_MAE] [int] NULL,
	[PLACA_REDE] [int] NULL,
	[MEMORIA] [int] NULL,
	[SOFTWARE] [int] NULL,
 CONSTRAINT [PK_Notebook] PRIMARY KEY CLUSTERED 
(
	[ETIQUETA] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ESTACAOTRABALHO]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ESTACAOTRABALHO](
	[ETIQUETA] [nvarchar](128) NOT NULL,
	[HD] [int] NULL,
	[MEMORIA] [nvarchar](64) NULL,
	[PLACA_MAE] [int] NULL,
	[SOFTWARE] [int] NULL,
	[PROCESSADOR] [int] NULL,
	[FONTE] [nvarchar](64) NULL,
	[POTENCIA_FONTE] [nvarchar](32) NULL,
	[DRIVERCD_DVD] [nvarchar](32) NULL,
	[FLOPY] [nvarchar](32) NULL,
	[USB] [nvarchar](32) NULL,
	[PLACA_DE_VIDEO] [int] NULL,
	[IP] [nvarchar](32) NULL,
PRIMARY KEY CLUSTERED 
(
	[ETIQUETA] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SERVIDOR]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[SERVIDOR](
	[ETIQUETA] [nvarchar](50) NOT NULL,
	[ETIQUETA_CONTINGENCIA] [nvarchar](50) NULL,
	[IP] [nvarchar](50) NULL,
	[GATEWAY] [nvarchar](50) NULL,
	[DNS] [nvarchar](50) NULL,
	[NUMERO_SERIE] [nvarchar](50) NULL,
	[PATRIMONIO] [nvarchar](50) NULL,
	[SALA] [nvarchar](50) NULL,
	[DEPARTAMENTO] [nvarchar](50) NULL,
	[STATUS] [nvarchar](50) NULL,
	[PLACA_MAE] [int] NULL,
	[PLACA_REDE] [int] NULL,
	[HD] [int] NULL,
PRIMARY KEY CLUSTERED 
(
	[ETIQUETA] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ETIQUETA]') AND parent_object_id = OBJECT_ID(N'[dbo].[NOTEBOOK]'))
ALTER TABLE [dbo].[NOTEBOOK]  WITH CHECK ADD  CONSTRAINT [FK_ETIQUETA] FOREIGN KEY([ETIQUETA])
REFERENCES [dbo].[EQUIPAMENTO] ([ETIQUETA])
GO
ALTER TABLE [dbo].[NOTEBOOK] CHECK CONSTRAINT [FK_ETIQUETA]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_HD]') AND parent_object_id = OBJECT_ID(N'[dbo].[NOTEBOOK]'))
ALTER TABLE [dbo].[NOTEBOOK]  WITH CHECK ADD  CONSTRAINT [FK_HD] FOREIGN KEY([HD])
REFERENCES [dbo].[HD] ([ID])
GO
ALTER TABLE [dbo].[NOTEBOOK] CHECK CONSTRAINT [FK_HD]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PLACA_MAE]') AND parent_object_id = OBJECT_ID(N'[dbo].[NOTEBOOK]'))
ALTER TABLE [dbo].[NOTEBOOK]  WITH CHECK ADD  CONSTRAINT [FK_PLACA_MAE] FOREIGN KEY([PLACA_MAE])
REFERENCES [dbo].[PLACA_MAE] ([ID])
GO
ALTER TABLE [dbo].[NOTEBOOK] CHECK CONSTRAINT [FK_PLACA_MAE]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PLACA_REDE]') AND parent_object_id = OBJECT_ID(N'[dbo].[NOTEBOOK]'))
ALTER TABLE [dbo].[NOTEBOOK]  WITH CHECK ADD  CONSTRAINT [FK_PLACA_REDE] FOREIGN KEY([PLACA_REDE])
REFERENCES [dbo].[PLACA_REDE] ([ID])
GO
ALTER TABLE [dbo].[NOTEBOOK] CHECK CONSTRAINT [FK_PLACA_REDE]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SOFTWARE]') AND parent_object_id = OBJECT_ID(N'[dbo].[NOTEBOOK]'))
ALTER TABLE [dbo].[NOTEBOOK]  WITH CHECK ADD  CONSTRAINT [FK_SOFTWARE] FOREIGN KEY([SOFTWARE])
REFERENCES [dbo].[SOFTWARE] ([ID])
GO
ALTER TABLE [dbo].[NOTEBOOK] CHECK CONSTRAINT [FK_SOFTWARE]
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__ESTACAOTR__ETIQU__117F9D94]') AND parent_object_id = OBJECT_ID(N'[dbo].[ESTACAOTRABALHO]'))
ALTER TABLE [dbo].[ESTACAOTRABALHO]  WITH CHECK ADD FOREIGN KEY([ETIQUETA])
REFERENCES [dbo].[EQUIPAMENTO] ([ETIQUETA])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__ESTACAOTR__PLACA__1273C1CD]') AND parent_object_id = OBJECT_ID(N'[dbo].[ESTACAOTRABALHO]'))
ALTER TABLE [dbo].[ESTACAOTRABALHO]  WITH CHECK ADD FOREIGN KEY([PLACA_MAE])
REFERENCES [dbo].[PLACA_MAE] ([ID])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__ESTACAOTR__PLACA__1367E606]') AND parent_object_id = OBJECT_ID(N'[dbo].[ESTACAOTRABALHO]'))
ALTER TABLE [dbo].[ESTACAOTRABALHO]  WITH CHECK ADD FOREIGN KEY([PLACA_DE_VIDEO])
REFERENCES [dbo].[PLACA_DE_VIDEO] ([ID])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__ESTACAOTR__PROCE__145C0A3F]') AND parent_object_id = OBJECT_ID(N'[dbo].[ESTACAOTRABALHO]'))
ALTER TABLE [dbo].[ESTACAOTRABALHO]  WITH CHECK ADD FOREIGN KEY([PROCESSADOR])
REFERENCES [dbo].[PROCESSADOR] ([ID])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__ESTACAOTR__SOFTW__15502E78]') AND parent_object_id = OBJECT_ID(N'[dbo].[ESTACAOTRABALHO]'))
ALTER TABLE [dbo].[ESTACAOTRABALHO]  WITH CHECK ADD FOREIGN KEY([SOFTWARE])
REFERENCES [dbo].[SOFTWARE] ([ID])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__ESTACAOTRABA__HD__164452B1]') AND parent_object_id = OBJECT_ID(N'[dbo].[ESTACAOTRABALHO]'))
ALTER TABLE [dbo].[ESTACAOTRABALHO]  WITH CHECK ADD FOREIGN KEY([HD])
REFERENCES [dbo].[HD] ([ID])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__SERVIDOR__HD__1BFD2C07]') AND parent_object_id = OBJECT_ID(N'[dbo].[SERVIDOR]'))
ALTER TABLE [dbo].[SERVIDOR]  WITH CHECK ADD FOREIGN KEY([HD])
REFERENCES [dbo].[HD] ([ID])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__SERVIDOR__PLACA___1CF15040]') AND parent_object_id = OBJECT_ID(N'[dbo].[SERVIDOR]'))
ALTER TABLE [dbo].[SERVIDOR]  WITH CHECK ADD FOREIGN KEY([PLACA_MAE])
REFERENCES [dbo].[PLACA_MAE] ([ID])
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__SERVIDOR__PLACA___1DE57479]') AND parent_object_id = OBJECT_ID(N'[dbo].[SERVIDOR]'))
ALTER TABLE [dbo].[SERVIDOR]  WITH CHECK ADD FOREIGN KEY([PLACA_REDE])
REFERENCES [dbo].[PLACA_REDE] ([ID])
